/*
 * Copyright (c) 2016-2021, Hangzhou Qulian Technology Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef _UTIL_H_
#define _UTIL_H_

#include "ql_type.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

ql_strings_t* CreateStringsT(void);

void FreeStringsT(ql_strings_t* in);

ql_size_t GetHexNumericSize(ql_uint64_t in);//how many bytes "in" need

// ql_int64_t getHexStringSize(char *in);
ql_strings_t* NumericToHexbytes(ql_uint64_t in);

char* BytesToHexstring(ql_byte_t* in, ql_int64_t inlen);

ql_strings_t* HexstringToBytes(char *in);

/*Description: Allocate memory in the heap for the string STR of length slen. This function is used because each function is designed to allocate a lot of memory, but free(string constant) will report an error
** Input: STR, the content of the string to be assigned
** slen, the length of the string to be allocated, if less than the length of STR, will be truncated when copying the contents of STR
** Return value: a string of length slen, memory space slen+1, and content in STR*/
ql_byte_t* StrMalloc(ql_byte_t* str, ql_size_t slen);
#endif